package com.zzptc.myapp1202;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;

import android.graphics.Color;
import android.os.Bundle;
import android.os.DropBoxManager;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //LineChart lineChart = findViewById(R.id.line_Chart);

        ViewPager viewPager = findViewById(R.id.viewPager);//创建新的集合
        final List<Fragment> fragments = new ArrayList<>();
        fragments.add(new FristFragment());
        fragments.add(new SecondFragment());
        fragments.add(new ThreeFragment());
        //绑定适配器
        FragmentStatePagerAdapter adapter = new FragmentStatePagerAdapter(getSupportFragmentManager()) {
            @Override
            public int getCount() {
                //返回集合长度
                return fragments.size();
            }

            @Override
            public Fragment getItem(int position) {
                //数据源的实例
                return fragments.get(position);
            }
        };
        viewPager.setAdapter(adapter);

    }
}

























        /*ArrayList<Entry> list = new ArrayList<>();


        list.add(new Entry(1, 2));
        list.add(new Entry(2, 3));
        list.add(new Entry(3, 8));
        list.add(new Entry(4, 0));
        list.add(new Entry(5, 1));

        ArrayList<Entry> list1 = new ArrayList<>();


        list1.add(new Entry(1, 8));
        list1.add(new Entry(2, 6));
        list1.add(new Entry(3, 7));
        list1.add(new Entry(4, 5));
        list1.add(new Entry(5, 3));

        LineDataSet lineDataSet = new LineDataSet(list, "");//设置参数 2个
        LineDataSet lineDataSet1 = new LineDataSet(list1, "");//设置参数 2个 这是第二个

        lineDataSet.setCircleColor(Color.RED);//设置标记点颜色
        lineDataSet.setCircleColor(Color.BLACK);//设置标记点颜色

        lineDataSet.setLineWidth(2f);//设置线的宽度
        ArrayList<ILineDataSet> iLineDataSets = new ArrayList<>();//双线并合
        iLineDataSets.add(lineDataSet);
        iLineDataSets.add(lineDataSet1);

        LineData lineData = new LineData(lineDataSet);
        lineChart.setData(lineData);

        XAxis xAxis = lineChart.getXAxis();//设置X轴
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);//设置X轴
        xAxis.setAxisMaximum(5);//设置最大值
        xAxis.setAxisMinimum(1);//设置最小值
        xAxis.setLabelCount(5);//设置设置标签计数


         */

